(function(angular) {
	"use strict";
	angular.module("fs.waf").factory("settlementPaymentFactory", settlementPaymentFactory);
	settlementPaymentFactory.$inject = [ "loggerFactory", "settlePaySwiftService", "settlePayCheckService", "settlePayInvoiceService", "settlePayDdaService", "settlePayDefaultService" ];
	function settlementPaymentFactory(loggerFactory, settlePaySwiftService, settlePayCheckService, settlePayInvoiceService, settlePayDdaService, settlePayDefaultService) {
		var log = loggerFactory.getLogger("settlementPaymentFactory");
		function getPayCodeService(payCodeObj) {
			if(!payCodeObj){
				return null;
			}
			var paycodeCat_substr = payCodeObj.paycodeCat.substr(7);
			if (paycodeCat_substr == "SWIFT") {
				return settlePaySwiftService;
			} else if (paycodeCat_substr == "CHECK") {
				return settlePayCheckService;
			} else if (paycodeCat_substr == "INVOICE") {
				return settlePayInvoiceService;
			} else if (paycodeCat_substr == "DDA") {
				return settlePayDdaService;
			} else {
				log.debug("not support");
				return null;
			}
		}

		function getFunction(payCodeObj, func) {
			var service = getPayCodeService(payCodeObj);
			if (service) {
				return service[func] ? service[func] : angular.noop;
			} else {
				return settlePayDefaultService[func] ? settlePayDefaultService[func] : angular.noop;
			}
		}

		return {
			getPayCodeService : getPayCodeService,
			getFunction : getFunction
		};
	}
})(angular);
